/**
 * Created by Administrator on 2017/3/2.
 */
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';
import { Jsonp, URLSearchParams,Response } from '@angular/http';
import { Observable }   from 'rxjs/Observable';
import 'rxjs/add/operator/catch';

@Injectable()
export class FactoryuploadService {
  constructor(private jsonp: Jsonp) {
  }

  public statu = '';
  private showfrom: boolean;

  faclist() {
    let wikiUrl = 'http://api.pinwu.net/site/upload';
    let params = new URLSearchParams();
    params.set('callback', 'JSONP_CALLBACK');

    return this.jsonp
      .get(wikiUrl, {search: params})
      .map((res: Response) => {
        let result = res.json();
        console.log(result);
        return result;
      });
  }

  login (email:string, pwd:string,invitation:string) {
    let wikiUrl = 'http://api.pinwu.net/site/login';
    let params = new URLSearchParams();
    params.set('pwd', pwd);                 // the user's repwd
    params.set('email', email);             // the user's email
    params.set('invitation', invitation);     // the user's name
    params.set('callback', 'JSONP_CALLBACK');

    return this.jsonp
      .get(wikiUrl, { search: params })
      .map((res:Response)=>{
        let result=res.json();
        console.log(result);
        return result;
      });
  }
  
}
